package io.sunny.platform.mcp.controller;

import io.sunny.platform.mcp.application.service.BookService;
import io.sunny.platform.mcp.domain.model.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author SUNNY
 * @Date 2025/12/4 14:35
 * @PackageName: io.sunny.platform.agent.mcp
 * @Description: TODO
 * @Version 1.0
 */
@RestController
@RequestMapping("/book")
@CrossOrigin(allowCredentials = "true", allowedHeaders = "*", originPatterns = "*")
public class BookController {
    @Autowired
    private BookService bookService;

    @RequestMapping(value = "/getBookByAuthor", method = {RequestMethod.GET, RequestMethod.POST})
    public ResponseEntity<List<Book>> findBooksByAuthor(@RequestParam("author") String author) {
        return ResponseEntity.ok(bookService.findBooksByAuthor(author));
    }

    @RequestMapping(value = "/getBookByCategory", method = {RequestMethod.GET, RequestMethod.POST})
    public ResponseEntity<List<Book>> findBooksByCategory(@RequestParam("category") String category) {
        return ResponseEntity.ok(bookService.findBooksByCategory(category));
    }
}
